<template>
<ProTable :request="request" :defaultCurrent="4" :defaultPageSize="1">
    <el-table-column type="selection" width="55" />
    <el-table-column prop="name" label="名称" width="180" />
    <el-table-column prop="label" label="标识" width="180" />
    <el-table-column prop="remark" label="备注" width="180" />
    <el-table-column prop="createTime" label="创建时间" width="180" />
    <el-table-column prop="updateTime" label="更新时间" width="180" />
    <el-table-column label="操作">
      <el-button>编辑</el-button>
      <el-button>删除</el-button>
    </el-table-column>
  </ProTable>
</template>

<script>
import ProTable from "@/components/pro-table/index.vue";
import { getRoleList } from "@/api/system";

export default {
  name: "Menu",

  components: {
    ProTable,
  },

  methods: {
    async request(params) {
      // params 就是分页的参数
      console.log("params", params);
      try {
        const result = await getRoleList({
          page: params.current,
          size: params.pageSize,
          order: "id",
          sort: "asc",
        });
        console.log("=== result", result);

        return {
          success: true, //
          list: result.list,
          total: result.pagination.total,
        };
      } catch (error) {
        // 如果有异常，则返回 success 为 false 的对象
        return {
          success: false,
        };
      }
    },
  },
};
</script>
